package com.hongguan.oms.service.plan;

import java.io.BufferedOutputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import com.hongguan.oms.domain.plan.PlanInfoModel;

public abstract class ExelWriter {

	public void exportExcel(HttpServletResponse response, PlanInfoModel plan,
			List<Map<String, Object>> listItem1, List<Map<String, Object>> listItem2) throws Exception {
		String fileName = plan.getPlanName() + ".xls";
		fileName = new String(fileName.getBytes("GBK"), "iso-8859-1");
		response.setContentType("application/x-msdownload");
		response.setHeader("Content-disposition", "attachment; filename=" + fileName);
		OutputStream os = new BufferedOutputStream(response.getOutputStream());
		writeExcel(os, plan, listItem1, listItem2);
		os.flush();
	}

	protected abstract void writeExcel(OutputStream os, PlanInfoModel plan, List<Map<String, Object>> listItem1,
			List<Map<String, Object>> listItem2) throws Exception;
}
